package com.test.listen;

import com.test.observer.Observer;
import com.test.observer.TestObserver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class Listen2 implements Observer {

    @Autowired
    TestObserver testObserver;

    @PostConstruct
    public void init() {
        //添加订阅Listen2
        testObserver.registerObserver(this);
    }

    @Override
    public void testObserver() {
        //收到通知后，执行具体操作
        System.out.println("Listen2.testObserver");
    }
}
